package com.enqualcomm.kids.mvp.oscard;

import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.enqualcomm.kids.R;
import com.facebook.drawee.view.SimpleDraweeView;

import java.util.List;

/**
 * Created by Yinzhiqun on 2016/8/5.
 */
public class PicturesAdapter extends RecyclerView.Adapter<PicturesAdapter.ViewHolder> {
    private LayoutInflater layoutInflater;
    private List<Uri> uris;
    public PicturesAdapter(LayoutInflater layoutInflater) {
        this.layoutInflater = layoutInflater;
    }


    public void setData(List<Uri> uris){
        this.uris =uris;
        notifyDataSetChanged();
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = layoutInflater.inflate(R.layout.item_oscard2, parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.simpleDraweeView.setImageURI(uris.get(position));
    }

    @Override
    public int getItemCount() {
        return uris==null?0:uris.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder{

        public SimpleDraweeView simpleDraweeView;
        public ViewHolder(View itemView) {
            super(itemView);
            simpleDraweeView = (SimpleDraweeView) itemView.findViewById(R.id.simpleDraweeView);
        }
    }
}
